package com.htht.smartschool.amq;

import javax.jms.JMSException;

import com.htht.smartschool.util.system.ConfigUtil;

/**
 * MQ消息发送工具
 * @author wangy
 * 2015年6月27日
 */
public class SeniorMessageSender {

	private static MessageSender inSender;
	
	
	private static String url = ConfigUtil.getProperty("activemq","url");
	private static String target = ConfigUtil.getProperty("activemq","targetsend");
	
	//将消息实体对象序列化后发送
	public static void sendMessage(String message){
		sendMessageWithMQ(message);
	}
	
	//消息发送
	private static void sendMessageWithMQ(String message){
		
		try {
			inSender = new MessageSender(url, target, true, 0, "");
			inSender.start();
			inSender.sendText(message);
			inSender.stop();
		} catch (JMSException e) {
			System.out.println("MQ使用出错!");
			e.printStackTrace();
		}
		
	}
	
}
